//
//  SwiftUIView.swift
//  MyCookbook
//
//  Created by liaokylin on 2024/10/16.
//

import SwiftUI

struct SwiftUIView: View {


    @FocusState private var isTextFieldFocused: Bool

    var body: some View {
        VStack {
            TextField("输入内容", text: .constant(""))
                .focused($isTextFieldFocused) // 绑定焦点状态
                .textFieldStyle(RoundedBorderTextFieldStyle())
                .padding()

            Button("唤起键盘") {
                isTextFieldFocused = true // 设置为 true 唤起键盘
            }
        }
        .padding()
    }
}




#Preview {
    SwiftUIView()
}
